home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c / 732 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  1.2 KB

  1. Path: solon.com!not-for-mail
  2. From: seebs@taniemarie.solon.com (Peter Seebach)
  3. Newsgroups: comp.std.c,comp.lang.c.moderated
  4. Subject: Re: printf() format extensions - looking for beta testers...
  5. Date: 12 Apr 1996 08:19:49 -0500
  6. Organization: Usenet Fact Police (Undercover)
  7. Sender: clc@solutions.solon.com
  8. Approved: clc@solutions.solon.com
  9. Message-ID: <4kll9l$o5h@solutions.solon.com>
  10. References: <4kgljv$l2p@solutions.solon.com> <4klicn$ndl@solutions.solon.com>
  11. NNTP-Posting-Host: solutions.solon.com
  12.  
  13. In article <4klicn$ndl@solutions.solon.com>,
  14. Ari Lukumies  <aril@cmt.lpr.mail.carel.fi> wrote:
  15. >Peter Seebach wrote:
  16. > >         int bangcvt(va_list *ap, char *s, int len, fmtspec *f) {
  17. > >                 strncpy(s, strerror(errno), len);
  18. > >                 s[len - 1] = '\0';
  19. > >                 return strlen(s);
  20. > >         }
  21.  
  22. >Given the above, how about calls like (well, not a pretty one, but you get the 
  23. >idea...):
  24.  
  25. >    fprintf(stderr, "%-*.2!", something);
  26.  
  27. This would call
  28.     bangcvt(&ap, buf, len, { '!', something, 2, FMT_LEFT });
  29. and leave the interpretation of the width and precision up to bangcvt.
  30. flags are or'ed together.
  31.  
  32. It might not work correctly; I think my sample implementation may have a bug
  33. in handling flags.  The principle is as given, though.
  34.  
  35. -s
  36.